from fastapi import APIRouter, Body
from backend.service.user_service import UserService
from backend.core.response import success_response, error_response

router = APIRouter()

@router.get("/")
async def get_users():
    """获取用户的列表"""
    users = UserService.get_users()
    return success_response(data=users).to_dict()

@router.post("/")
async def create_user(user_data: dict = Body(...)):
    """创建新用户"""
    new_user = UserService.create_user(user_data)
    return success_response(data=new_user, message="用户创建成功").to_dict()